package com.cskaoyan.service;

import com.cskaoyan.bean.*;
import com.cskaoyan.mapper.GoodsMapper;
import com.cskaoyan.mapper.GoodsProductMapper;
import com.cskaoyan.mapper.OrderMapper;
import com.cskaoyan.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IndexServiceImpl implements IndexService {
    @Autowired
    GoodsMapper goodsMapper;
    @Autowired
    UserMapper userMapper;
    @Autowired
    OrderMapper orderMapper;
    @Autowired
    GoodsProductMapper goodsProductMapper;

    @Override
    public DashBoardVO selectTotal() {
        GoodsExample goodsExample = new GoodsExample();
        int goodsTotal = (int) goodsMapper.countByExample(goodsExample);
        UserExample userExample = new UserExample();
        int userTotal = (int) userMapper.countByExample(userExample);
        OrderExample orderExample = new OrderExample();
        int orderTotal = (int) orderMapper.countByExample(orderExample);
        GoodsProductExample goodsProductExample = new GoodsProductExample();
        int productTotal = (int) goodsProductMapper.countByExample(goodsProductExample);
        DashBoardVO boardVO = new DashBoardVO();
        boardVO.setGoodsTotal(goodsTotal);
        boardVO.setUserTotal(userTotal);
        boardVO.setOrderTotal(orderTotal);
        boardVO.setProductTotal(productTotal);
        return boardVO;
    }
}
